<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改账号</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /><!-- 控制浏览器文件模式为IE8 -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="js/artDialog/skins/default.css" rel="stylesheet" type="text/css" />
<link href="css/sele.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/artDialog/artDialog.js?skin=blue"></script>
<script src="js/artDialog/plugins/iframeTools.js"></script>
<script type="text/javascript" src="js/operamasks-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/elegant/om-all.css" />
<script> 
(function (config) {
    config['lock'] = true;
    config['fixed'] = true;
    config['okVal'] = 'Ok';
    config['cancelVal'] = 'Cancel';
})(art.dialog.defaults);
</script>
<script language="javascript">
	var j = jQuery.noConflict();
	j.ajaxSetup({
		cache:false,
		async: false
	});
</script>
<script>
function submitForm() {
	var realName = document.getElementById("realName").value;
	var flag = true;
	if(realName == null || realName == ""){
		art.dialog.tips('真实名不能为空！', 1.5);
		flag = false;
		return;
	}
	var email = document.getElementById("email").value;
	var phone = document.getElementById("phone").value;
	var telePhone = document.getElementById("telePhone").value;

	 var patrn = /^(13[0-9]|15[0-9]|18[0-9]|14[0-9])\d{8}$/; //检测手机号码	
	if(phone == null || phone == ""){}else{
		if(!patrn.test(phone)){
			art.dialog.tips('您的手机号码格式不正确！', 1.5);
			flag=false;
			return false;
		}
	} 
	if(telePhone == null || telePhone == ""){
		art.dialog.tips('分机不能为空！', 1.5);
		flag = false;
		return;
	}
	var m = /^\d{3}\+\d{5}|\d{4}\+\d{4}$/;
	if(!m.test(telePhone)){
		art.dialog.tips('分机格式不正确！', 1.5);
		flag = false;
		return;
	}
	if(email == null || email == ""){
	}else{
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(email)) {
			art.dialog.tips('您的电子邮件格式不正确！', 1.5);
			flag=false;
			return ;
		}
	}
	if(flag){
		document.forms[0].submit();
	}
}
</script>
</head>
<body>

	<div class="place">
	    <span>位置：</span>
	    <ul class="placeul">
	    <li>首页</li>
		<li>系统管理</li>
	    <li><a href="#" onclick="javascript:window.location.href='./adminUser.do?action=list'"> 账号管理</a></li>
		<li>修改账号</li>
	    </ul>
    </div>
    <div class="rightinfo">
		<form id="form1" action="./adminUser.do?action=edit" method="post">

			<ul class="seachform">
				<li>
					<label>用户登录名：</label>
					<input id="userName" type="text" disabled="disabled" value="${users.loginName }" name="loginName" size="10" style="width:100px;height:32px;" class="scinput" autocomplete="off"/>
					<input type="hidden" name="userId" value="${users.adminId }"></input>
				</li>
				<li>
					<label>&nbsp;&nbsp;电话：</label>
				    <input id="phone" type="text" name="phone" size="10" value="${users.phone }" style="width:200px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
				<li>
					<label>分机：</label>
					<input id="telePhone" type="text" name="telePhone" size="10" value="${users.telePhone }" style="width:200px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
			</ul>
			<ul class="seachform">
				<li>
					<label>用户真实名：</label>
				    <input id="realName" type="text" name="realName" size="10" value="${users.realName }" style="width:100px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
				<li>
					<label>Email：</label>
					<input id="email" type="text" name="email" size="10" value="${users.email }" style="width:200px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
				
				<li>
					<label>描述：</label>
					<input id="description" type="text" name="description" value="${users.description }" size="10" style="width:200px;height:32px;" class="scinput" autocomplete="off"/>
				</li>
			</ul>
        <table class="tablelist">
				<thead>
					<tr>
						<td>序号</td>
            			<td>角色名称</td>
            			<td>角色分配</td>
					</tr>
				</thead>
				<tbody>
					<c:set var="i" value="0" />
				<c:forEach var="list" items="${roleBeanList}">
					<c:set var="i" value="${i+1}" />
					<tr>
						<td>${i }</td>
						<td>${list.role.roleName}</td>
						<td><input type="checkbox" style="width:20px;" name="roleId" value="${list.role.roleId }" <c:if test="${list.isUsedInUser=='1' }">checked="checked" </c:if><c:if test="${users.loginName=='admin'&& list.role.roleCode=='ROLE_ADMIN'}"> onclick="return false;"  </c:if> /></td>
			        </tr>
		        </c:forEach>
				</tbody>
			</table>
          	<ul class="forminfo" style="margin-top:30px;">
			    <li>
					<label>&nbsp;</label>
					<input name="" type="button" id="save" onclick="submitForm();" class="btn" value="确定修改"/> 
					<input style="margin-left:100px;" onclick="javascript:document.location.href = './adminUser.do?action=list';" type="button" class="cancel" value="取消修改" />
				</li>
		    </ul>   
	    </form>
	</div>
	<script type="text/javascript">
	window.onload = function()
	{
		var isAddSuccess = '${isAddSuccess}';
		var roleName = '${roleName}';
		if(isAddSuccess == "success"){
			j.omMessageBox.alert({
				content:'修改成功！',
				onClose:function(v){
					document.location.href = './adminUser.do?action=list';
				}
		    });
		}
		else if(isAddSuccess == "error"){
			j.omMessageBox.alert({
				content:'修改失败！',
				onClose:function(v){}
		    });
		}
		else if(isAddSuccess == "exsit"){
			j.omMessageBox.alert({
				content:'角色【'+roleName+'】已被使用，请到【工作流程管理】-【流程权限管理】取消该角色的相关权限后再修改！',
				onClose:function(v){
					document.location.href = './adminUser.do?action=list';
				}
		    });
		}
	};
	</script>
</body>
</html>